const mongoose = require('mongoose');
const articleSchema = new mongoose.Schema({
    title: {
        type: String,
        required: true,
    },
    content: {
        type: String,
        required: true,
    },
    imageUrls: {
        type: [String],
        required: true,
    },
    author: {
        type: mongoose.Schema.Types.ObjectId,
        ref: 'User',
        required: true,
        comment:'关联用户表的objectid作为外键'
    },
    created_at: {
        type: Date,
        default: Date.now,
    },
    updated_at: {
        type: Date,
        default: Date.now,
    },
    status: {
        type: Number,
        default: 0,
        comment:'0/草稿 1/上线  2/下架  3/逻辑删除'
    }
});

const Article = mongoose.model('Article', articleSchema);

module.exports = Article;